
@protocol MHLazyTableImageCell <NSObject>

/*!
 * Invoked when the image has finished loading.
 *
 * @param image the UIImage or nil if the image failed to load
 */
- (void)didLoadLazyImage:(UIImage*)image;

@end

/*!
 * By default, UITableViewCell puts lazily loaded images into its imageView.
 */
@interface UITableViewCell (MHLazyTableImages) <MHLazyTableImageCell>
@end

/*!
 * Your view controller should implement this protocol in order to connect your
 * data model to the lazy image loading system.
 */
@protocol MHLazyTableImagesDelegate <NSObject>

/*! Returns the URL for the row at the specified index-path. */
- (NSURL*)lazyImageURLForIndexPath:(NSIndexPath*)indexPath;

@optional

/*!
 * Implement this to perform post-processing on the image, such as scaling it
 * to the desired dimensions. This will insert the altered image into the cache
 * and remove the original.
 */
- (UIImage*)postProcessLazyImage:(UIImage*)image forIndexPath:(NSIndexPath*)indexPath;

@end

@interface MHLazyTableImages : NSObject
{
    int noNeedDownloadRow;
}
@property(nonatomic,assign) int noNeedDownloadRow;
/*! The delegate object. */
@property (nonatomic, assign) id<MHLazyTableImagesDelegate> delegate;

/*! Weak reference to the table view on whose behalf we are working. */
@property (nonatomic, assign) UITableView* tableView;

/*! Temporary image that is shown while the real image is loading. */
@property (nonatomic, retain) UIImage* placeholderImage;

/*!
 * Adds a lazily-loaded image to a table view cell.
 */
- (void)addLazyImageForCell:(id<MHLazyTableImageCell>)cell withIndexPath:(NSIndexPath*)indexPath;

/*!
 * You should call this method from your UIScrollView delegate.
 */
- (void)scrollViewDidEndDragging:(UIScrollView*)scrollView willDecelerate:(BOOL)decelerate;

/*!
 * You should call this method from your UIScrollView delegate.
 */
- (void)scrollViewDidEndDecelerating:(UIScrollView*)scrollView;



@end
